<%--
  Created by IntelliJ IDEA.
  User: chen
  Date: 17-8-21
  Time: 下午5:41
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>this is deleteProduct</title>
    <script src="js/jquery-3.2.1.min.js"></script>
</head>
<body>
<div align="center" style="width: 100%">
    <label for="_input_id">请输入想要删除的ID</label>
    <br/>
    <input name="id" id="_input_id"/>
    <br/>
    <input type="submit" id="_input_submit"  value="删除"/>
</div>
<script type="text/javascript">
    var _input_sub = $("input#_input_submit");
    var _input_id = $("input#_input_id");
    
    function deleteClick(id) {
        $.ajax({
            //发送POST请求
            url:"deleteProduct",
            type:"POST",
            data:{
                id:id
            },
            success:function (data) {
                if(data === "success"){
                    alert("删除成功");
                }else{
                    alert("失败")
                }
            }
        });
    }

    _input_sub.click(function () {
        var id = _input_id.val();
        if("" === id){
            alert("请先输入id");
            return;
        }
        /**
         * 添加一个查询到的Product信息
         * 此处将data转化为Product对象并输出相关信息
         */
        var temp = window.confirm("确定删除ID为:"+id+"的信息吗？");
        if(temp = true){
            deleteClick(id)
        }
    });
</script>
</body>
</html>
